//
// Created by dxm on 2025/4/10.
//

// #include "hello.h"

#include <iostream>
#include <vector>

int countSymmetricIntegers(int i, int i1);

class Solution
{
public:
    Solution()
    {
    }

    int countSubarrays(std::vector<int> &nums)
    {
        int ans = 0;
        for (int i = 0; i < nums.size() - 2; ++i)
        {
            int a = nums[i];
            int b = nums[i + 1];
            int c = nums[i + 2];
            if (b / 2 == a + c)
            {
                ans++;
            }
        }
        return ans;
    }
};


int* get_pointer_int(){
    int a = 10;
    int *p = &a;
    std::cout << "*P value = "<< *p << std::endl;
    std::cout << "p value = "<< p << std::endl;
    return p;
}

int main()
{
    std::cout << "Hello, World!" << std::endl;
    int a = countSymmetricIntegers(1, 1000);
    std::cout << a << std::endl;
    Solution solution;
    int nums[] = {1, 2};
    std::vector<int> vectors;
    vectors.push_back(-1);
    vectors.push_back(-4);
    vectors.push_back(-1);
    vectors.push_back(4);
    int ans = solution.countSubarrays(vectors);
    std::printf("countSubarrays ans = %d ", ans);
    //测试指针指向栈内变量返回的是什么
    int *p = get_pointer_int();
    std::cout << "*P value = "<< *p << std::endl;
    std::cout << "p value = "<< p << std::endl;

    return 0;
}


int countSymmetricIntegers(int low, int high)
{
    int res = 0;
    for (int a = low; a <= high; ++a)
    {
        if (a < 100 && a % 11 == 0)
        {
            res++;
        }
        else if (1000 <= a && a < 10000)
        {
            int left = a / 1000 + (a % 1000) / 100;
            int right = (a % 100) / 10 + a % 10;
            if (left == right)
            {
                res++;
            }
        }
    }
    return res;
}
